package otSpaces.msg;

/**
 * 
 * 
 * Listing of all messages used by OT
 * 
 * 
 * Downstream means server -> client
 * 
 * @author peter.lavalle@gmail.com
 */
public enum MessageTypes {
	/**
	 * Probably the most frequently sent message. Sent from server to clients to
	 * pass them a buffer within a channel
	 * 
	 * <ul>
	 * <li>byte: Type=JOIN the type ordinal as a byte</li>
	 * <li>-payload-</li>
	 * <li>short number of bytes in the contents byte[] bytes that make up the
	 * contents</li>
	 * </ul>
	 */
	DOWNSTREAM,

	/**
	 * Sent from the server to a client to tell them that they have been joint
	 * to a channel
	 * 
	 * <ul>
	 * <li>byte: Type=JOIN the type ordinal as a byte</li>
	 * <li>short: topicId the id that the host will use to send downstream
	 * messages</li>
	 * <li>-payload-</li>
	 * <li>String channel name</li>
	 * </ul>
	 */
	JOIN,

	/**
	 * Sent from the server to a client to tell them that they are no longer a
	 * member of the passed channel
	 * 
	 * Contains the only `paranoid` transmitted data
	 * 
	 * <ul>
	 * <li>byte: Type=JOIN the type ordinal as a byte</li>
	 * <li>short: topicId the id of the topic (that is now closed)</li>
	 * <li>-payload-</li>
	 * <li>byte channel name.foldHashCode used to double check that we're really
	 * subscribed</li>
	 * </ul>
	 */
	LEAVE,

	UNUSED,

	/**
	 * Sent from client to server to "speak" on a channel
	 * 
	 * <ul>
	 * <li>byte: Type=JOIN the type ordinal as a byte</li>
	 * <li>-payload-</li>
	 * <li>byte a byte identifying the topicName.foldHashCode. should be checked
	 * by the host before processign the message</li>
	 * <li>short number of bytes in the contents</li>
	 * <li>byte[] bytes that make up the contents</li>
	 * </ul>
	 */
	UPSTREAM

};
